
package vip.xiaonuo.biz.modular.lancerGoodsTag.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.pojo.vo.KV;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.common.pojo.CommonValidList;
import vip.xiaonuo.biz.modular.lancerGoodsTag.entity.BizGoodsTag;
import vip.xiaonuo.biz.modular.lancerGoodsTag.param.BizGoodsTagAddParam;
import vip.xiaonuo.biz.modular.lancerGoodsTag.param.BizGoodsTagEditParam;
import vip.xiaonuo.biz.modular.lancerGoodsTag.param.BizGoodsTagIdParam;
import vip.xiaonuo.biz.modular.lancerGoodsTag.param.BizGoodsTagPageParam;
import vip.xiaonuo.biz.modular.lancerGoodsTag.service.BizGoodsTagService;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 商品标签表控制器
 *
 * @author Lancer
 * @date 2024/03/13 15:55
 */
@Api(tags = "商品标签控制器(管理端)")
@ApiSupport(author = "LANCER_TEAM", order = 1)
@RestController
@Validated
public class BizGoodsTagController {

    @Resource
    private BizGoodsTagService bizGoodsTagService;

    /**
     * 获取商品标签表分页
     *
     * @author Lancer
     * @date 2024/03/13 15:55
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("管理端获取商品标签表分页")
    @SaCheckPermission("/biz/admin/lancerGoodsTag/page")
    @GetMapping("/biz/admin/lancerGoodsTag/page")
    public CommonResult<Page<BizGoodsTag>> page(BizGoodsTagPageParam bizGoodsTagPageParam) {
        return CommonResult.data(bizGoodsTagService.page(bizGoodsTagPageParam));
    }

    /**
     * 添加商品标签表
     *
     * @author Lancer
     * @date 2024/03/13 15:55
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("管理端添加商品标签表")
    @CommonLog("添加商品标签表")
    @SaCheckPermission("/biz/admin/lancerGoodsTag/add")
    @PostMapping("/biz/admin/lancerGoodsTag/add")
    public CommonResult<String> add(@RequestBody @Valid BizGoodsTagAddParam bizGoodsTagAddParam) {
        bizGoodsTagService.add(bizGoodsTagAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑商品标签表
     *
     * @author Lancer
     * @date 2024/03/13 15:55
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation("管理端编辑商品标签表")
    @CommonLog("编辑商品标签表")
    @SaCheckPermission("/biz/admin/lancerGoodsTag/edit")
    @PostMapping("/biz/admin/lancerGoodsTag/edit")
    public CommonResult<String> edit(@RequestBody @Valid BizGoodsTagEditParam bizGoodsTagEditParam) {
        bizGoodsTagService.edit(bizGoodsTagEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除商品标签表
     *
     * @author Lancer
     * @date 2024/03/13 15:55
     */
    @ApiOperationSupport(order = 4)
    @ApiOperation("管理端删除商品标签表")
    @CommonLog("删除商品标签表")
    @SaCheckPermission("/biz/admin/lancerGoodsTag/delete")
    @PostMapping("/biz/admin/lancerGoodsTag/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                       CommonValidList<BizGoodsTagIdParam> bizGoodsTagIdParamList) {
        bizGoodsTagService.delete(bizGoodsTagIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取商品标签表详情
     *
     * @author Lancer
     * @date 2024/03/13 15:55
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("管理端获取商品标签表详情")
    @SaCheckPermission("/biz/admin/lancerGoodsTag/detail")
    @GetMapping("/biz/admin/lancerGoodsTag/detail")
    public CommonResult<BizGoodsTag> detail(@Valid BizGoodsTagIdParam bizGoodsTagIdParam) {
        return CommonResult.data(bizGoodsTagService.detail(bizGoodsTagIdParam));
    }

    @ApiOperationSupport(order = 5)
    @ApiOperation("管理端获取所有标签")
    @SaCheckPermission("/biz/admin/lancerGoodsTag/allTag")
    @GetMapping("/biz/admin/lancerGoodsTag/allTag")
    public CommonResult<List<KV>> allTag() {
        return CommonResult.data(bizGoodsTagService.allTag());
    }

}
